/*
Copyright (C) 2009  Raymond Jeon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef __GL_MAIL_CONFIG_H__
#define __GL_MAIL_CONFIG_H__


typedef struct
{
	char	*szName;
	int		iParentChild;
	BOOL	(*func) (void *pvData, char *szVal, char *szArg);
	int		iAttr;
} glconfig_;



#define CONFIG_PARENT				1
#define CONFIG_CHILD				2
#define CONFIG_ALL					3


void GlConfigRead(char *szFile, glconfig_ *config, void *pvData, int iParentChild);
BOOL GlConfigReadBlock(glconfig_ *config, void *pvData, char *szLine, FILE *fp, int iParentChild);
BOOL GlConfigReadLine(glconfig_ *config, void *pvData, char *szLine, int iParentChild);


#define CONFIG_OK					0
#define CONFIG_ERROR_LOCK			1
#define CONFIG_ERROR_FILE			2
#define CONFIG_ERROR_DUP			3
#define CONFIG_ERROR_NOT			4
#define CONFIG_ERROR_MEMORY			5
#define CONFIG_ERROR_ARG			6



#define CONFIG_LINESET				0
#define CONFIG_BLOCKLINEADD			1
#define CONFIG_BLOCKLINEDEL			2
#define CONFIG_BLOCKLINESADD		3
#define CONFIG_BLOCKLINESDEL		4
#define CONFIG_BLOCKLINESMEMBERADD	5
#define CONFIG_BLOCKLINESMEMBERDEL	6
#define CONFIG_BLOCKCSVADD			7
#define CONFIG_BLOCKCSVDEL			8
#define CONFIG_BLOCKSET				9
#define CONFIG_BLOCKLIST			10


int GlConfigReadSet(glsocketstream_ *stream, char *szFile, char *szName, char *szVal, char *szArg, char *pMember, int iMode);
int GlConfigReadSetWithLock(glsocketstream_ *stream, char *szFile, char *szName, char *szVal, char *szArg, int iMode);
int GlConfigBlockLineView(glsocketstream_ *stream, char *szFile, char *szName, char *szVal, char *szArg);

int GlConfigBlockLineAdd(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockLineDel(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockLinesAdd(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockLinesDel(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockLinesMemberAdd(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockLinesMemberDel(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockCsvAdd(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockCsvDel(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigBlockSet(char *szFile, char *szName, char *szVal, char *szArg);
int GlConfigLineSet(char *szFile, char *szName, char *szVal);			// line



#endif	// __GL_MAIL_CONFIG_H__